//////////////////////////////////////////////////////////////////////
// PlugInHelper.h
//
// SHEN Fangyang
// me@shenfy.com
//
// Copyright (C) SHEN Fangyang, 2011, All rights reserved.
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
//  Brief Description
//
//	Plugin selector functions
//
//////////////////////////////////////////////////////////////////////
#pragma once
#include <D3D10Engine.h>
#include <Octree.h>
#include <OctreeFake.h> //for debug
#include <string>
#include <algorithm>
#include <Logger.h>

namespace grflib
{
	namespace engine
	{
		namespace aux
		{
			template<typename TObj, typename TRenderQueue>
			HRESULT SelectSceneGraph(std::string strType)
			{
				HRESULT hr = S_OK;

				std::transform(strType.begin(), strType.end(), strType.begin(), tolower);
				if (strType == "octree")
				{
					//COctreeFake<TObj, TRenderQueue> *pOctree = new COctreeFake<TObj, TRenderQueue>;
					COctree<TObj, TRenderQueue> *pOctree = new COctree<TObj, TRenderQueue>;
					if (pOctree)
						_SceneMan.SetSceneGraph(pOctree);
					else
					{
						W32ERR(_T("Failed to create Octree scene manager!"));
						return E_FAIL;
					}
				}
				else if (strType == "kdtree")
				{
					//TODO: add support for other scene managers
				}
				else
				{
					W32ERR(_T("Unrecognized scene manager type!"));
					return E_FAIL;
				}

				return hr;
			}
		} // namespace aux
	} //namespace engine
} //namespace grflib

